package ModelLayer;
import java.util.ArrayList;

public class Person
{
    private int id;
    private String name;
    private String address;
    private String postalCode;
    private String city;
    private String phone;
    private ArrayList<Lend> lend;

    public Person(int id, String name, String address, String postalCode, String city, String phone)
    {
        this.id = id;
        this.name = name;
        this.address = address;
        this.postalCode = postalCode;
        this.city = city;
        this.phone = phone;
        lend = new ArrayList<Lend>();
    }

    public int getId()
    {
        return id;
    }
    
    public String getName()
    {
        return name;
    }
    
    public String getAddress()
    {
        return address;
    }
    
    public String getPostalCode()
    {
        return postalCode;
    }
    
    public String getCity()
    {
        return city;
    }
    
    public String getphone()
    {
        return phone;
    }
    
    /**
     * Update person
     */
    public void updatePerson(String name, String address, String postalCode, String city, String phone)
    {
        this.name = name;
        this.address = address;
        this.postalCode = postalCode;
        this.city = city;
        this.phone = phone;
    }
    
    /**
     * Add lend
     */
    public void addLending(Lend lend)
    {
        this.lend.add(lend);
    }
    
    public Lend getLend(int id)
    {
        for(Lend l : lend) {
            if(l.getId() == id){
                return l;
            }
        }
        return null;
    }
    
}
